package com.jike.buyi.system.menu.dao.impl;

import com.jike.buyi.system.menu.dao.MenuDao;
import com.jike.buyi.system.menu.domain.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MenuDaoImpl implements MenuDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<MenuVo> queryAll() {
        String sql =" select t.*,t1.text as parentmenutext from tmenu t LEFT JOIN tmenu t1 on t.parentmenuid = t1.menuid order by  t.menulevel desc ,t.sortno asc ";
        List<MenuVo> l = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(MenuVo.class));
        return l;
    }
}
